<?php
/**
 * Created by PhpStorm.
 * User: jason
 * Date: 18-8-23
 * Time: 下午3:23
 */
require "vendor/autoload.php";
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;
class writelog
{
    public $log;
    const DB = DIRECTORY_SEPARATOR;


    public static function addlog($path = '' , $log_content ,$data = []){
        $log = new Logger('log');
        $pathAll = __DIR__. self::DB .'log'. self::DB .$path;
        $logPath = substr($pathAll , 0 ,strrpos($pathAll,self::DB) + 1);
        if (!is_dir($logPath)) {
            mkdir($logPath,755,true);
        }
        //echo $pathAll;die;
        $log->pushHandler(new StreamHandler($pathAll, Logger::INFO));
        $log->pushHandler(new FirePHPHandler());
        $log->addInfo($log_content , $data);
    }
}
$logpath = date('Ymd') . DIRECTORY_SEPARATOR . 'account.log';
writelog::addlog($logpath,'添加用户',['user_id'=>1,'user_name'=>'luojunwei']);

